/*
 * @Description:
 * @Author: lipenghui
 * @Date: 2023-07-26 17:58:56
 * @LastEditors: lipenghui
 * @LastEditTime: 2023-07-26 18:06:20
 */
export const useOpenFile = (fileUrl: string) => {
  let result = fileUrl.substr(fileUrl.lastIndexOf(".") + 1, fileUrl.length);
  uni.downloadFile({
    url: fileUrl,
    success: function (res) {
      var filePath = res.tempFilePath;
      console.log(res);
      uni.openDocument({
        filePath: filePath,
        fileType: result,
        success: function (res) {
          console.log("打开文档成功");
        },
      });
    },
    fail: function (res) {
      console.log(res);
    },
  });
};
